import applicationApi from "../../utils/api/application";

const state = {
	appSelectList: [],  // 查询条件appList
	bizSelectList: [],  // 查询条件bizList
	appList: [],        // 分页appList
	bizList: [],        // 分页bizList
	orgCodeObj: {}, // 集团/省份数据
	businessTypeObj: {}, // 栏目大类数据
	eventTypeList: [],  // 事件类型数据
	actionTypeList: [],
	actionEffectList: [],
	pageUpdateStatusObj: {},
	propertyList: [],    // 属性列表,
	categoryList: [],   // 类别列表
	propertyTypeList: [],  // 属性类别列表
	dataTypeList: [],     // 数据类别
	pageNavigate: [],    // 位置导航
	imageUrl: null,      // 添加埋点，图片显示
	dicList: [],				// 字典列表
};
const mutations = {
	QUERY_BIZ_LIST(state, value) {
		state.bizList = value;
	},
	QUERY_BIZ_SELECT_LIST(state, value) {
		state.bizSelectList = value;
	},
	QUERY_APP_LIST(state, value) {
		state.appList = value;
	},
	QUERY_APP_SELECT_LIST(state, value) {
		state.appSelectList = value;
	},
	QUERY_ORG_LIST(state, value) {
		state.orgCodeObj = value;
	},
	QUERY_BUSINESS_TYPE_LIST(state, value) {
		state.businessTypeObj = value;
	},
	QUERY_EVENT_TYPE_LIST(state, value) {
		state.eventTypeList = value;
	},
	QUERY_PROPERTY_LIST(state, value) {
		state.propertyList = value;
	},
	QUERY_CATEGORY_LIST(state, value) {
		state.categoryList = value;
	},
	QUERY_PROPERTY_TYPE_LIST(state, value) {
		state.propertyTypeList = value;
	},
	QUERY_DATA_TYPE_LIST(state, value) {
		state.dataTypeList = value;
	},
	QUERY_PAGE_NAVIGATE_LIST(state, value) {
		state.pageNavigate = value;
	},
	QUERY_DIC_LIST(state, value) {
		state.dicList = value;
	},
	SET_IMAGE_URL(state, value) {
		state.imageUrl = value;
	}
};
const actions = {
	async getBizSelectList({commit}, {hasEventCollectData, needSimpleData}) {
		let res = await applicationApi.biz_list({
			hasEventCollectData,
			needSimpleData,
			currentPage: 1,
			pageSize: 10000
		});
		if (res) {
			commit("QUERY_BIZ_SELECT_LIST", res.value.list);
		}
	},
	async getBizList({commit}, {appId, hasEventCollectData, needSimpleData}) {
		let res = await applicationApi.biz_list({
			hasEventCollectData,
			needSimpleData,
			appId,
			currentPage: 1,
			pageSize: 10000
		});
		if (res) {
			commit("QUERY_BIZ_LIST", res.value.list);
		}
	},
	async getAppSelectList({commit}) {
		let res = await applicationApi.app_list({
			currentPage: 1,
			pageSize: 10000
		});
		if (res) {
			commit("QUERY_APP_SELECT_LIST", res.value.list);
		}
	},
	async getAppList({commit}, {appName, currentPage, pageSize}) {
		let res = await applicationApi.app_list({
			appName,
			currentPage,
			pageSize
		});
		if (res) {
			commit("QUERY_APP_LIST", res.value.list);
		}
	},
	async getOrgList({commit}) {
		let res = await applicationApi.meta_data_query({
			type: "organization_code"
		});
		if (res) {
			commit("QUERY_ORG_LIST", res.value.data);
		}
	},
	async getBusinessTypeList({commit}) {
		let res = await applicationApi.meta_data_query({
			type: "business_type"
		});
		if (res) {
			commit("QUERY_BUSINESS_TYPE_LIST", res.value.data);
		}
	},
	async getEventTypeList({commit}, {commonType}) {
		let res = await applicationApi.event_list({
			commonType,
			currentPage: 1,
			pageSize: 10000,
		});
		if (res) {
			commit("QUERY_EVENT_TYPE_LIST", res.value.list);
		}
	},
	async getPropertyList({commit}) {
		let res = await applicationApi.property_list({
			currentPage: 1,
			pageSize: 10000
		});
		if (res) {
			commit("QUERY_PROPERTY_LIST", res.value.list);
		}
	},
	async getPropertyTypeList({commit}) {
		let res = await applicationApi.property_property({
			type: "propertyType"
		});
		if (res) {
			commit("QUERY_PROPERTY_TYPE_LIST", res.value.list);
		}
	},
	async getDataTypeList({commit}) {
		let res = await applicationApi.property_property({
			type: "dataType"
		});
		if (res) {
			commit("QUERY_DATA_TYPE_LIST", res.value.list);
		}
	},
	async getCategoryList({commit}) {
		let res = await applicationApi.property_property({
			type: "category"
		});
		if (res) {
			commit("QUERY_CATEGORY_LIST", res.value.list);
		}
	},
	async getDicList({commit}, data) {
		let res = await applicationApi.dic_list(data);
		if (res) {
			commit("QUERY_DIC_LIST", res.value.list);
		}
	}
};
const getters = {};

export default {
	state,
	mutations,
	actions,
	getters
}
